home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 April: Penguin on DISC / ADC Developer CD (1993-04) (''Penguin On DISC'')_iso / Dev.CD Apr 93.iso / Utilities / MPW Interfaces 7.1 Beta / PInterfaces / PPCToolBox.p < prev    next >
Encoding:
Text File  |  1992-08-28  |  13.3 KB  |  379 lines  |  [TEXT/MPS ]

  1.  
  2. {
  3. Created: Thursday, September 5, 1991 at 5:57 PM
  4.  PPCToolBox.p
  5.  Pascal Interface to the Macintosh Libraries
  6.  
  7.   Copyright Apple Computer, Inc. 1989-1991
  8.   All rights reserved
  9. }
  10.  
  11.  
  12. {$IFC UNDEFINED UsingIncludes}
  13. {$SETC UsingIncludes := 0}
  14. {$ENDC}
  15.  
  16. {$IFC NOT UsingIncludes}
  17.  UNIT PPCToolBox;
  18.  INTERFACE
  19. {$ENDC}
  20.  
  21. {$IFC UNDEFINED UsingPPCToolBox}
  22. {$SETC UsingPPCToolBox := 1}
  23.  
  24. {$I+}
  25. {$SETC PPCToolBoxIncludes := UsingIncludes}
  26. {$SETC UsingIncludes := 1}
  27. {$IFC UNDEFINED UsingAppleTalk}
  28. {$I $$Shell(PInterfaces)AppleTalk.p}
  29. {$ENDC}
  30. {$IFC UNDEFINED UsingMemory}
  31. {$I $$Shell(PInterfaces)Memory.p}
  32. {$ENDC}
  33. {$IFC UNDEFINED UsingTypes}
  34. {$I $$Shell(PInterfaces)Types.p}
  35. {$ENDC}
  36. {$SETC UsingIncludes := PPCToolBoxIncludes}
  37.  
  38. TYPE
  39. PPCServiceType = SignedByte;
  40.  
  41. CONST
  42. ppcServiceRealTime = 1;
  43.  
  44. TYPE
  45. PPCLocationKind = INTEGER;
  46.  
  47. CONST
  48. ppcNoLocation = 0;                            { There is no PPCLocName }
  49. ppcNBPLocation = 1;                            { Use AppleTalk NBP      }
  50. ppcNBPTypeLocation = 2;                        { Used for specifying a location name type during PPCOpen only }
  51.  
  52. TYPE
  53. PPCPortKinds = INTEGER;
  54.  
  55. CONST
  56. ppcByCreatorAndType = 1;                    { Port type is specified as colloquial Mac creator and type }
  57. ppcByString = 2;                            { Port type is in pascal string format }
  58.  
  59. TYPE
  60. PPCSessionOrigin = SignedByte;                { Values returned for request field in PPCInform call }
  61.  
  62. CONST
  63.  
  64. { Values returned for requestType field in PPCInform call }
  65. ppcLocalOrigin = 1;                            { session originated from this machine }
  66. ppcRemoteOrigin = 2;                        { session originated from remote machine }
  67.  
  68. TYPE
  69. PPCPortRefNum = INTEGER;
  70. PPCSessRefNum = LONGINT;
  71.  
  72. PPCPortPtr = ^PPCPortRec;
  73. PPCPortRec = RECORD
  74.  nameScript: ScriptCode;                    { script of name }
  75.  name: Str32;                                { name of port as seen in browser }
  76.  portKindSelector: PPCPortKinds;            { which variant }
  77.  CASE PPCPortKinds OF
  78.    ppcByString:
  79.   (portTypeStr: Str32);
  80.    ppcByCreatorAndType:
  81.   (portCreator: OSType;
  82.   portType: OSType);
  83.  END;
  84.  
  85. LocationNamePtr = ^LocationNameRec;
  86. LocationNameRec = RECORD
  87.  locationKindSelector: PPCLocationKind;        { which variant }
  88.  CASE PPCLocationKind OF
  89.    ppcNBPLocation:
  90.   (nbpEntity: EntityName);                    { NBP name entity }
  91.    ppcNBPTypeLocation:
  92.   (nbpType: Str32);                            { just the NBP type string, for PPCOpen }
  93.  END;
  94.  
  95. PortInfoPtr = ^PortInfoRec;
  96. PortInfoRec = RECORD
  97.  filler1: SignedByte;
  98.  authRequired: BOOLEAN;
  99.  name: PPCPortRec;
  100.  END;
  101.  
  102.  
  103. PortInfoArrayPtr = ^PortInfoArray;
  104. PortInfoArray = ARRAY [0..0] OF PortInfoRec;
  105. { Procedures you will need to write }
  106. PPCFilterProcPtr = ProcPtr;                    { FUNCTION MyPortFilter(locationName: LocationNameRec; thePortInfo: PortInfoRec): BOOLEAN; }
  107. PPCCompProcPtr = ProcPtr;                    { PROCEDURE MyCompletionRoutine(pb: PPCParamBlockPtr); }
  108.  
  109. PPCOpenPBPtr = ^PPCOpenPBRec;
  110. PPCOpenPBRec = RECORD
  111.     qLink:   Ptr;                             { reserved }
  112.     csCode:   INTEGER;                        { reserved }
  113.     intUse:   INTEGER;                        { reserved }
  114.     intUsePtr:  Ptr;                         { reserved }
  115.     ioCompletion: PPCCompProcPtr;
  116.     ioResult:  OSErr;
  117.     reserved:  ARRAY [1..5] OF LONGINT;        { reserved }
  118.     portRefNum:  PPCPortRefNum;               { 38 <--   Port Reference          }   
  119.     filler1:  LONGINT;     
  120.     serviceType: PPCServiceType;               { 44 -->   Bit field describing the requested port service  } 
  121.     resFlag:  SignedByte;                    { 45 -->   Must be set to 0          }
  122.     portName:  PPCPortPtr;                    { 46 -->   PortName for PPC           }
  123.     locationName: LocationNamePtr;          { 50 -->   If NBP  Registration is required       }
  124.     networkVisible: BOOLEAN;                 { 54 -->   make this network visible on network      }
  125.     nbpRegistered: BOOLEAN;                 { 55 <--   The given location name was registered on the network }
  126.    END;
  127.  
  128. PPCInformPBPtr = ^PPCInformPBRec;
  129. PPCInformPBRec = RECORD
  130.  qLink: Ptr;                                { reserved }
  131.  csCode: INTEGER;                            { reserved }
  132.  intUse: INTEGER;                            { reserved }
  133.  intUsePtr: Ptr;                            { reserved }
  134.  ioCompletion: PPCCompProcPtr;
  135.  ioResult: OSErr;
  136.  reserved: ARRAY [1..5] OF LONGINT;            { reserved }
  137.  portRefNum: PPCPortRefNum;                    { 38 -->   Port Identifier }
  138.  sessRefNum: PPCSessRefNum;                    { 40 <--   Session Reference }
  139.  serviceType: PPCServiceType;                { 44 <--   Status Flags for type of session, local, remote }
  140.  autoAccept: BOOLEAN;                        { 45 -->   if true session will be accepted automatically }
  141.  portName: PPCPortPtr;                        { 46 -->   Buffer for Source PPCPortRec }
  142.  locationName: LocationNamePtr;                { 50 -->   Buffer for Source LocationNameRec }
  143.  userName: StringPtr;                        { 54 -->   Buffer for Soure user's name trying to link. }
  144.  userData: LONGINT;                            { 58 <--   value included in PPCStart's userData }
  145.  requestType: PPCSessionOrigin;                { 62 <--   Local or Network }
  146.  END;
  147.  
  148. PPCStartPBPtr = ^PPCStartPBRec;
  149. PPCStartPBRec = RECORD
  150.  qLink: Ptr;                                { reserved }
  151.  csCode: INTEGER;                            { reserved }
  152.  intUse: INTEGER;                            { reserved }
  153.  intUsePtr: Ptr;                            { reserved }
  154.  ioCompletion: PPCCompProcPtr;
  155.  ioResult: OSErr;
  156.  reserved: ARRAY [1..5] OF LONGINT;            { reserved }
  157.  portRefNum: PPCPortRefNum;                    { 38 -->   Port Identifier }
  158.  sessRefNum: PPCSessRefNum;                    { 40 <--   Session Reference }
  159.  serviceType: PPCServiceType;                { 44 <--   Actual service method (realTime) }
  160.  resFlag: SignedByte;                        { 45 -->   Must be set to 0  }
  161.  portName: PPCPortPtr;                        { 46 -->   Destination portName }
  162.  locationName: LocationNamePtr;                { 50 -->   NBP or NAS style service location name }
  163.  rejectInfo: LONGINT;                        { 54 <--   reason for rejecting the session request }
  164.  userData: LONGINT;                            { 58 -->   Copied to destination PPCInform parameter block }
  165.  userRefNum: LONGINT;                        { 62 -->   userRefNum (obtained during login process)  }
  166.  END;
  167.  
  168. PPCAcceptPBPtr = ^PPCAcceptPBRec;
  169. PPCAcceptPBRec = RECORD
  170.  qLink: Ptr;                                { reserved }
  171.  csCode: INTEGER;                            { reserved }
  172.  intUse: INTEGER;                            { reserved }
  173.  intUsePtr: Ptr;                            { reserved }
  174.  ioCompletion: PPCCompProcPtr;
  175.  ioResult: OSErr;
  176.  reserved: ARRAY [1..5] OF LONGINT;            { reserved }
  177.  filler1: INTEGER;
  178.  sessRefNum: PPCSessRefNum;                    { 40 -->   Session Reference }
  179.  END;
  180.  
  181. PPCRejectPBPtr = ^PPCRejectPBRec;
  182. PPCRejectPBRec = RECORD
  183.  qLink: Ptr;                                { reserved }
  184.  csCode: INTEGER;                            { reserved }
  185.  intUse: INTEGER;                            { reserved }
  186.  intUsePtr: Ptr;                            { reserved }
  187.  ioCompletion: PPCCompProcPtr;
  188.  ioResult: OSErr;
  189.  reserved: ARRAY [1..5] OF LONGINT;            { reserved }
  190.  filler1: INTEGER;
  191.  sessRefNum: PPCSessRefNum;                    { 40 -->   Session Reference }
  192.  filler2: INTEGER;
  193.  filler3: LONGINT;
  194.  filler4: LONGINT;
  195.  rejectInfo: LONGINT;                        { 54 -->   reason for rejecting the session request  }
  196.  END;
  197.  
  198. PPCWritePBPtr = ^PPCWritePBRec;
  199. PPCWritePBRec = RECORD
  200.  qLink: Ptr;                                { reserved }
  201.  csCode: INTEGER;                            { reserved }
  202.  intUse: INTEGER;                            { reserved }
  203.  intUsePtr: Ptr;                            { reserved }
  204.  ioCompletion: PPCCompProcPtr;
  205.  ioResult: OSErr;
  206.  reserved: ARRAY [1..5] OF LONGINT;            { reserved }
  207.  filler1: INTEGER;
  208.  sessRefNum: PPCSessRefNum;                    { 40 -->   Session Reference }
  209.  bufferLength: Size;                        { 44 -->   Length of the message buffer }
  210.  actualLength: Size;                        { 48 <--   Actual Length Written }
  211.  bufferPtr: Ptr;                            { 52 -->   Pointer to message buffer }
  212.  more: BOOLEAN;                                { 56 -->   if more data in this block will be written }
  213.  filler2: SignedByte;
  214.  userData: LONGINT;                            { 58 -->   Message block userData Uninterpreted by PPC }
  215.  blockCreator: OSType;                        { 62 -->   Message block creator Uninterpreted by PPC }
  216.  blockType: OSType;                            { 66 -->   Message block type Uninterpreted by PPC }
  217.  END;
  218.  
  219. PPCReadPBPtr = ^PPCReadPBRec;
  220. PPCReadPBRec = RECORD
  221.  qLink: Ptr;                                { reserved }
  222.  csCode: INTEGER;                            { reserved }
  223.  intUse: INTEGER;                            { reserved }
  224.  intUsePtr: Ptr;                            { reserved }
  225.  ioCompletion: PPCCompProcPtr;
  226.  ioResult: OSErr;
  227.  reserved: ARRAY [1..5] OF LONGINT;            { reserved }
  228.  filler1: INTEGER;
  229.  sessRefNum: PPCSessRefNum;                    { 40 -->   Session Reference }
  230.  bufferLength: Size;                        { 44 -->   Length of the message buffer }
  231.  actualLength: Size;                        { 48 <--   Actual length read }
  232.  bufferPtr: Ptr;                            { 52 -->   Pointer to message buffer }
  233.  more: BOOLEAN;                                { 56 <--   if true more data in this block to be read }
  234.  filler2: SignedByte;
  235.  userData: LONGINT;                            { 58 <--   Message block userData Uninterpreted by PPC }
  236.  blockCreator: OSType;                        { 62 <--   Message block creator Uninterpreted by PPC }
  237.  blockType: OSType;                            { 66 <--   Message block type Uninterpreted by PPC }
  238.  END;
  239.  
  240. PPCEndPBPtr = ^PPCEndPBRec;
  241. PPCEndPBRec = RECORD
  242.  qLink: Ptr;                                { reserved }
  243.  csCode: INTEGER;                            { reserved }
  244.  intUse: INTEGER;                            { reserved }
  245.  intUsePtr: Ptr;                            { reserved }
  246.  ioCompletion: PPCCompProcPtr;
  247.  ioResult: OSErr;
  248.  reserved: ARRAY [1..5] OF LONGINT;            { reserved }
  249.  filler1: INTEGER;
  250.  sessRefNum: PPCSessRefNum;                    { 40 -->   Session Reference }
  251.  END;
  252.  
  253. PPCClosePBPtr = ^PPCClosePBRec;
  254. PPCClosePBRec = RECORD
  255.  qLink: Ptr;                                { reserved }
  256.  csCode: INTEGER;                            { reserved }
  257.  intUse: INTEGER;                            { reserved }
  258.  intUsePtr: Ptr;                            { reserved }
  259.  ioCompletion: PPCCompProcPtr;
  260.  ioResult: OSErr;
  261.  reserved: ARRAY [1..5] OF LONGINT;            { reserved }
  262.  portRefNum: PPCPortRefNum;                    { 38 -->   Port Identifier }
  263.  END;
  264.  
  265. IPCListPortsPBPtr = ^IPCListPortsPBRec;
  266. IPCListPortsPBRec = RECORD
  267.  qLink: Ptr;                                { reserved }
  268.  csCode: INTEGER;                            { reserved }
  269.  intUse: INTEGER;                            { reserved }
  270.  intUsePtr: Ptr;                            { reserved }
  271.  ioCompletion: PPCCompProcPtr;
  272.  ioResult: OSErr;
  273.  reserved: ARRAY [1..5] OF LONGINT;            { reserved }
  274.  filler1: INTEGER;
  275.  startIndex: INTEGER;                        { 40 -->   Start Index }
  276.  requestCount: INTEGER;                        { 42 -->   Number of entries to be returned }
  277.  actualCount: INTEGER;                        { 44 <--   Actual Number of entries to be returned }
  278.  portName: PPCPortPtr;                        { 46 -->   PortName Match }
  279.  locationName: LocationNamePtr;                { 50 -->   NBP or NAS type name to locate the Port Location }
  280.  bufferPtr: PortInfoArrayPtr;                { 54 -->   Pointer to a buffer requestCount*sizeof(PortInfo) bytes big }
  281.  END;
  282.  
  283. PPCParamBlockPtr = ^PPCParamBlockRec;
  284. PPCParamBlockRec = RECORD
  285.      CASE Integer OF
  286.       0: (openParam:   PPCOpenPBRec);
  287.       1: (informParam: PPCInformPBRec);
  288.       2: (startParam:  PPCStartPBRec);
  289.       3: (acceptParam: PPCAcceptPBRec);
  290.       4: (rejectParam: PPCRejectPBRec);
  291.       5: (writeParam:  PPCWritePBRec);
  292.       6: (readParam:   PPCReadPBRec);
  293.       7: (endParam:  PPCEndPBRec);
  294.       8: (closeParam:  PPCClosePBRec);
  295.       9: (listPortsParam: IPCListPortsPBRec);
  296.     END;
  297.  
  298.  
  299.  
  300. {  PPC Calling Conventions  }
  301. FUNCTION PPCInit: OSErr;
  302.  INLINE $7000,$A0DD,$3E80;
  303. FUNCTION PPCOpen(pb: PPCOpenPBPtr;async: BOOLEAN): OSErr;
  304. FUNCTION PPCOpenSync(pb: PPCOpenPBPtr): OSErr;
  305.  INLINE $205F,$7001,$A0DD,$3E80;
  306. FUNCTION PPCOpenAsync(pb: PPCOpenPBPtr): OSErr;
  307.  INLINE $205F,$7001,$A4DD,$3E80;
  308. FUNCTION PPCInform(pb: PPCInformPBPtr;async: BOOLEAN): OSErr;
  309. FUNCTION PPCInformSync(pb: PPCInformPBPtr): OSErr;
  310.  INLINE $205F,$7003,$A0DD,$3E80;
  311. FUNCTION PPCInformAsync(pb: PPCInformPBPtr): OSErr;
  312.  INLINE $205F,$7003,$A4DD,$3E80;
  313. FUNCTION PPCStart(pb: PPCStartPBPtr;async: BOOLEAN): OSErr;
  314. FUNCTION PPCStartSync(pb: PPCStartPBPtr): OSErr;
  315.  INLINE $205F,$7002,$A0DD,$3E80;
  316. FUNCTION PPCStartAsync(pb: PPCStartPBPtr): OSErr;
  317.  INLINE $205F,$7002,$A4DD,$3E80;
  318. FUNCTION PPCAccept(pb: PPCAcceptPBPtr;async: BOOLEAN): OSErr;
  319. FUNCTION PPCAcceptSync(pb: PPCAcceptPBPtr): OSErr;
  320.  INLINE $205F,$7004,$A0DD,$3E80;
  321. FUNCTION PPCAcceptAsync(pb: PPCAcceptPBPtr): OSErr;
  322.  INLINE $205F,$7004,$A4DD,$3E80;
  323. FUNCTION PPCReject(pb: PPCRejectPBPtr;async: BOOLEAN): OSErr;
  324. FUNCTION PPCRejectSync(pb: PPCRejectPBPtr): OSErr;
  325.  INLINE $205F,$7005,$A0DD,$3E80;
  326. FUNCTION PPCRejectAsync(pb: PPCRejectPBPtr): OSErr;
  327.  INLINE $205F,$7005,$A4DD,$3E80;
  328. FUNCTION PPCWrite(pb: PPCWritePBPtr;async: BOOLEAN): OSErr;
  329. FUNCTION PPCWriteSync(pb: PPCWritePBPtr): OSErr;
  330.  INLINE $205F,$7006,$A0DD,$3E80;
  331. FUNCTION PPCWriteAsync(pb: PPCWritePBPtr): OSErr;
  332.  INLINE $205F,$7006,$A4DD,$3E80;
  333. FUNCTION PPCRead(pb: PPCReadPBPtr;async: BOOLEAN): OSErr;
  334. FUNCTION PPCReadSync(pb: PPCReadPBPtr): OSErr;
  335.  INLINE $205F,$7007,$A0DD,$3E80;
  336. FUNCTION PPCReadAsync(pb: PPCReadPBPtr): OSErr;
  337.  INLINE $205F,$7007,$A4DD,$3E80;
  338. FUNCTION PPCEnd(pb: PPCEndPBPtr;async: BOOLEAN): OSErr;
  339. FUNCTION PPCEndSync(pb: PPCEndPBPtr): OSErr;
  340.  INLINE $205F,$7008,$A0DD,$3E80;
  341. FUNCTION PPCEndAsync(pb: PPCEndPBPtr): OSErr;
  342.  INLINE $205F,$7008,$A4DD,$3E80;
  343. FUNCTION PPCClose(pb: PPCClosePBPtr;async: BOOLEAN): OSErr;
  344. FUNCTION PPCCloseSync(pb: PPCClosePBPtr): OSErr;
  345.  INLINE $205F,$7009,$A0DD,$3E80;
  346. FUNCTION PPCCloseAsync(pb: PPCClosePBPtr): OSErr;
  347.  INLINE $205F,$7009,$A4DD,$3E80;
  348. FUNCTION IPCListPorts(pb: IPCListPortsPBPtr;async: BOOLEAN): OSErr;
  349. FUNCTION IPCListPortsSync(pb: IPCListPortsPBPtr): OSErr;
  350.  INLINE $205F,$700A,$A0DD,$3E80;
  351. FUNCTION IPCListPortsAsync(pb: IPCListPortsPBPtr): OSErr;
  352.  INLINE $205F,$700A,$A4DD,$3E80;
  353.  
  354. FUNCTION DeleteUserIdentity(userRef: LONGINT): OSErr;
  355. FUNCTION GetDefaultUser(VAR userRef: LONGINT;
  356.                         VAR userName: Str32): OSErr;
  357. FUNCTION StartSecureSession(pb: PPCStartPBPtr;
  358.                             VAR userName: Str32;
  359.                             useDefault: BOOLEAN;
  360.                             allowGuest: BOOLEAN;
  361.                             VAR guestSelected: BOOLEAN;
  362.                             prompt: Str255): OSErr;
  363. FUNCTION PPCBrowser(prompt: Str255;
  364.                     applListLabel: Str255;
  365.                     defaultSpecified: BOOLEAN;
  366.                     VAR theLocation: LocationNameRec;
  367.                     VAR thePortInfo: PortInfoRec;
  368.                     portFilter: PPCFilterProcPtr;
  369.                     theLocNBPType: Str32): OSErr;
  370.  INLINE $303C,$0D00,$A82B;
  371.  
  372.  
  373. {$ENDC} { UsingPPCToolBox }
  374.  
  375. {$IFC NOT UsingIncludes}
  376.  END.
  377. {$ENDC}
  378.  
  379.